/**
 * 
 */
package org.statewalker.validator.impl;

import org.statewalker.validator.IParseKey;
import org.statewalker.validator.IParseState;
import org.statewalker.validator.IParseToken;

public class ParseToken implements IParseToken {

    private IParseKey fKey;

    private boolean fOpen;

    public ParseToken(IParseKey key) {
        this(key, true);
    }

    public ParseToken(IParseKey key, boolean open) {
        fKey = key;
        fOpen = open;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this)
            return true;
        if (!(obj instanceof IParseState))
            return false;
        ParseToken o = (ParseToken) obj;
        return fKey.equals(o.fKey);
    }

    /**
     * @see org.statewalker.validator.IParseToken#getKey()
     */
    public IParseKey getKey() {
        return fKey;
    }

    @Override
    public int hashCode() {
        return fKey.hashCode();
    }

    /**
     * @see org.statewalker.validator.IParseToken#isOpen()
     */
    public boolean isOpen() {
        return fOpen;
    }

    @Override
    public String toString() {
        return fKey.toString();
    }
}